package top.continew.admin.controller.qywx;

import cn.shengchao.examstar.rpc.base.PageResult;
import cn.shengchao.examstar.rpc.wecom.api.EmployeeUserBindApi;
import cn.shengchao.examstar.rpc.wecom.req.EmployeeUserPageQuery;
import cn.shengchao.examstar.rpc.wecom.req.WeComUserQuery;
import cn.shengchao.examstar.rpc.wecom.req.WeComUserState;
import cn.shengchao.examstar.rpc.wecom.resp.EmployeeUserBindDetailVo;
import cn.shengchao.examstar.rpc.wecom.resp.EmployeeUserVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;
import top.continew.admin.req.wecom.EmployeeUserRto;
import top.continew.starter.web.model.R;

import java.util.List;

/**
 * @program: examstar-manger-api
 * @description: 成员企微号绑定业务
 * @author: Xiong weiqiang
 * @create: 2025-04-09 15:07
 */

@Tag(name = "企微-成员企微号绑定业务")
@RestController
@RequestMapping("/qywx/employeeBind")
public class EmployeeUserController {
    @DubboReference
    private EmployeeUserBindApi employeeUserBindApi;
    /**
     * 分页查询成员企微号绑定列表
     * @param pageQuery
     * @return
     */
    @Operation(summary = "成员企微号绑定列表", description = "成员企微号绑定列表")
    @GetMapping("/pageQuery")
    PageResult<EmployeeUserVo> pageQuery(EmployeeUserPageQuery pageQuery) {
        return employeeUserBindApi.queryUserWeComBind(pageQuery);
    }
    /**
     * 成员企微号可选的列表
     * @param userQuery
     * @return
     */
    @Operation(summary = "成员企微号可选的列表", description = "成员企微号可选的列表")
    @GetMapping("/weComUserList")
    R<List<WeComUserState>> wecomUserList(WeComUserQuery userQuery) {
        List<WeComUserState> list=employeeUserBindApi.listWeComUserByQuery(userQuery);
        return R.ok(list);
    }
    /**
     * 成员企微号绑定详情
     * @param sysUserId
     * @return
     */
    @Operation(summary = "成员企微号绑定详情", description = "成员企微号绑定详情")
    @GetMapping("/detail/{sysUserId}")
    R<EmployeeUserBindDetailVo> detail(@PathVariable Long sysUserId) {
        EmployeeUserBindDetailVo vo=employeeUserBindApi.getEmployeeUserBindDetail(sysUserId);
        return R.ok(vo);
    }

    /**
     * 成员企微号绑定保存
     * @param employeeUserRto
     * @return
     */
    @Operation(summary = "成员企微号绑定保存", description = "成员企微号绑定保存")
    @PostMapping("/save")
    R save(@RequestBody EmployeeUserRto employeeUserRto) {
        employeeUserBindApi.saveUserWeComBind(employeeUserRto.toDto());
        return R.ok();
    }

    /**
     * 成员企微号绑定保存
     * @param sysUserId
     * @return
     */
    @Operation(summary = "成员企微号绑定删除", description = "成员企微号绑定删除")
    @PostMapping("/delete/{sysUserId}")
    R delete(@PathVariable Long sysUserId) {
        employeeUserBindApi.delUserWeComBind(sysUserId);
        return R.ok();
    }
}